/*
 * @Author: CodeHare
 * @Date: 2023-09-19 18:46:23
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-04-23 11:10:48
 * @Description: 
 */
import 'package:get/get.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/utils/enums.dart';

class RectangleControlInstructModel {
  /// 指令集Socket值
  late Map instructSocketMap = {};

  /// 系统启动状态值
  String sysStartStatus = '';

  /// 系统停止状态值
  String sysStopStatus = '';

  /// 系统复位状态值
  String sysRestStatus = '';

  /// BMS主接触器闭合状态值
  String bmsCloseStatus = '';

  /// BMS主接触器断开状态值
  String bmsBreakStatus = '';

  /// 手/自动切换状态值
  String manualAutomaticSwitcStatus = '';

  /// 离并网切换状态值
  String parallelOffGridModeSwitcStatus = '1';

  /// 请求参数
  var params = {};

  /// 存在系统复位功能
  bool canReset = false;

  /// 控制指令列表
  List<RectangleControlInstructItem> instructList(int? productId) {
    if (!canReset) {
      return [
        RectangleControlInstructItem('siteMonitor.controlCommand'.tr, false),
        RectangleControlInstructItem('siteMonitor.systemStartup'.tr, false),
        RectangleControlInstructItem('siteMonitor.systemHalt'.tr, false),
        RectangleControlInstructItem(
            'BMS ${'siteMonitor.mainContactorClosed'.tr}', false),
        RectangleControlInstructItem(
            'BMS ${'siteMonitor.mainContactorDisconnected'.tr}', false),
        RectangleControlInstructItem(
            'siteMonitor.manualAutomaticSwitch'.tr, false),
      ];
    }

    return [
      RectangleControlInstructItem('siteMonitor.controlCommand'.tr, false),
      RectangleControlInstructItem('siteMonitor.systemStartup'.tr, false),
      RectangleControlInstructItem('siteMonitor.systemHalt'.tr, false),
      RectangleControlInstructItem(
          'BMS ${'siteMonitor.mainContactorClosed'.tr}', false),
      RectangleControlInstructItem(
          'BMS ${'siteMonitor.mainContactorDisconnected'.tr}', false),
      RectangleControlInstructItem(
          'siteMonitor.manualAutomaticSwitch'.tr, false),
      RectangleControlInstructItem('siteMonitor.systemReset'.tr, false),
      if (productId == ProductIDType.react100XEmsEnergy.value)
        RectangleControlInstructItem(
            ResKey.deviceAndOffGridSwitching.tr, false),
    ];
  }
}

/// 控制指令
class RectangleControlInstructItem {
  /// 描述
  String label;

  /// 启动按钮值
  bool open;

  RectangleControlInstructItem(
    this.label,
    this.open,
  );
}
